package com.ayoka.parenting.adapter;

import android.graphics.Color;
import android.graphics.ColorMatrix;
import android.graphics.ColorMatrixColorFilter;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.BasicUserInfoBean;
import com.jincp.common.brvah.BaseQuickAdapter;
import com.jincp.common.brvah.BaseViewHolder;
import com.jincp.common.utils.MyLogger;
import com.jincp.common.utils.UIUtils;
import com.jincp.image.load.ImageLoader;
import com.jincp.image.load.ImageLoaderOptions;


/**
 * @ProjectName: ayoka7.
 * @ClassName: CourseClassroomMemberAdapter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/8/6 21:15.
 */

public class DiscussGroupMemberAdapter extends BaseQuickAdapter<BasicUserInfoBean, BaseViewHolder> {


    public DiscussGroupMemberAdapter() {
        super(R.layout.item_discuss_group_member, null);
    }

    @Override
    protected void convert(BaseViewHolder holder, BasicUserInfoBean item) {
        MyLogger.d(TAG, item.toString());
        ImageView header = holder.getView(R.id.iv_header);
        ImageLoader.getInstance().displayImage(item.LocalAvatar, header , ImageLoaderOptions.getCircleOptions());
        if (item.isOnline) {
            header.clearColorFilter();
        } else {
            ColorMatrix colorMatrix = new ColorMatrix();
            colorMatrix.setSaturation(0);
            ColorMatrixColorFilter colorMatrixColorFilter = new ColorMatrixColorFilter(colorMatrix);
            header.setColorFilter(colorMatrixColorFilter);
        }
        ImageView speaking = holder.getView(R.id.iv_speaking);
        speaking.setColorFilter(UIUtils.getColor(R.color.colorPrimary));
        if (item.isSpeaking) {
            speaking.setVisibility(View.VISIBLE);
        } else {
            speaking.setVisibility(View.GONE);
        }
        TextView tvName = holder.getView(R.id.tv_name);
        tvName.setText(item.WeixinNickName);
    }

}
